<template>
    <view class="container">
        <view class="main">
            <view class="card-group">
                <card-cell-input
                    ref="oldPwd"
                    label="当前密码"
                    :inputType="'password'"
                    placeholder="请输入当前密码"></card-cell-input>
                <card-cell-input
                    ref="newPwd"
                    label="新密码"
                    :inputType="'password'"
                    placeholder="请输入新的密码"></card-cell-input>
                <card-cell-input
                    ref="pwd"
                    label="确认密码"
                    :inputType="'password'"
                    placeholder="请重新输入新的密码"></card-cell-input>
            </view>
            <button class="btn btn-success btn-save" @click="submit">保存</button>
        </view>
    </view>
</template>

<script>
import { UpdatePassword } from "@/pages_supplier/service/api/authorize.js"
import cardCellInput from "@/pages_supplier/components/common/cell/card-cell-input.vue"

export default {
    components: {
        cardCellInput,
    },
    data() {
        return {
            usrInfo: {},
        }
    },
    mounted() {},
    methods: {
        //密码修改
        submit() {
            if (this.$refs.oldPwd.getValue() == "") {
                this.easyToast("请输入当前密码")
                return
            }
            if (this.$refs.newPwd.getValue() == "") {
                this.easyToast("请输入新的密码")
                return
            }
            if (this.$refs.pwd.getValue() == "") {
                this.easyToast("请重新输入新的密码")
                return
            }
            if (this.$refs.pwd.getValue() != this.$refs.newPwd.getValue()) {
                this.easyToast("确认密码不一致")
                return
            }
            let path = "?oldPwd=" + this.$refs.oldPwd.getValue() + "&pwd=" + this.$refs.pwd.getValue()
            UpdatePassword(path).then((res) => {
                if (res.State == 1) {
                    this.easyToast("修改成功")
                    setTimeout((e) => {
                        this.easyGoBack()
                    }, 800)
                } else {
                    this.easyToast(res.Msg)
                }
            })
        },
    },
}
</script>

<style lang="scss">
.main {
    padding: $app-page-padding;
}

.btn-save {
    margin-top: 40rpx;
    height: 88rpx;
    font-size: 32rpx;
    border-radius: 44rpx;
    color: $app-color-main;
    background: none;
    border: 2rpx solid $app-color-main;
}
.card-group-cell {
    text {
        font-size: 30rpx;
    }
    input {
        font-size: 30rpx;
    }
}
.btn {
    margin-left: 36rpx;
    margin-right: 36rpx;
}
</style>
